﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Utils.MathUtilitys;

namespace Utils.Misc
{
    public class RndUtils
    {
        static Random random = new Random();

        public static float Rndf()
        {
            return (float)random.NextDouble();
        }

        public static int RndPlusMinus()
        {
            return random.Next() % 2 == 0 ? -1 : +1;
        }

        public static float RndfInRange(float min, float max)
        {
            return min + (float)random.NextDouble() * (max - min);
        }

        public static float RndfInRange(RangeValue<float> range)
        {
            return RndfInRange(range.Min, range.Max);
        }

        public static int RndInRange(int min, int max)
        {
            return min + random.Next() % (max - min + 1);
        }

        public static int RndInRange(RangeValue<int> range)
        {
            return RndInRange(range.Min, range.Max);
        }

        public static bool Chance(float per)
        {
            return random.NextDouble() <= per;
        }
    }
}
